package top.hzy520.aop;

import top.hzy520.log.entity.SysLoginLog;
import top.hzy520.log.entity.SysOperationLog;

import java.util.Date;

/**
 * @Author: HouZeYu
 * @Description: 日志对象创建工厂
 * @Date: Created in 15:06 2018/9/20
 */
public class LogFactory {
    /***
     *
     * @param logType
     * @param logName
     * @param userId
     * @param className
     * @param method
     * @param message
     * @param status
     * @return 操作日志信息
     */
    public static SysOperationLog createOperationLog(LogType logType,String logName,Long userId,String className,String method,String message,Byte status){
        SysOperationLog operationLog=new SysOperationLog();
        operationLog.setLogName(logName);
        operationLog.setLogType(logType.getMessage());
        operationLog.setClassName(className);
        operationLog.setMethod(method);
        operationLog.setUserUuid(userId);
        operationLog.setLogMessage(message);
        operationLog.setLogStatus(status);
        operationLog.setCreateTime(new Date());
        return operationLog;
    }

    /***
     *
     * @param logType 日志类型
     * @param username 用户名字
     * @param message 日志备注信息
     * @param ip 操作ip
     * @param status 操作状态
     * @return 登录日志信息
     */
    public static SysLoginLog createLoginLog(LogType logType,String username,String message,String ip,Byte status){
      SysLoginLog loginLog=new SysLoginLog();
      loginLog.setLogName(logType.getMessage());
      loginLog.setLoginUsername(username);
      loginLog.setLoginIp(ip);
      loginLog.setLoginMessage(message);
      loginLog.setLoginStatus(status);
      loginLog.setLoginTime(new Date());
      return loginLog;
    }
}
